package depth_width_list;

import java.util.List;

public class Travel {
	public static void deepTravel(List<List<Cell>> list){
	 	int[] mark=new int[list.size()];
		travel(list,mark,0);
	}//0 1 2 3 10 6 8 5 4 7 9 
	public static void travel(List<List<Cell>> list,int[] mark,int i){
		System.out.print(i+" ");
		mark[i]=1;
		for(int j=0;j<list.get(i).size();j++){
			if((list.get(i).get(j).getWeight()!=0)&&(mark[list.get(i).get(j).getNode()])==0){
				travel(list,mark,list.get(i).get(j).getNode());
			}
		}
	}
	//******************************************************
	public static void widthTravel(List<List<Cell>> list){
		int[] mark=new int[list.size()];
		for(int i=0;i<list.size();i++){
		    if(mark[i]==0){
			    System.out.print(i+" ");
			    mark[i]=1;
		     }
			for(int j=0;j<list.get(i).size();j++){
			    if((list.get(i).get(j).getWeight()!=0)&&(mark[list.get(i).get(j).getNode()])==0){
			      System.out.print(list.get(i).get(j).getNode()+" ");
			      mark[list.get(i).get(j).getNode()]=1;
			    }		
			}
		}
	}
}
